<?php

class entity
{
	private $id;
	private $name;
	private $password;
	private $email;
	private $rank;
	private $blocked;

	public function setAll_fromDB($data)
	{
		$this->set_id($data["id"]);
		$this->set_name($data["name"]);
		$this->set_email($data["mail"]);
		$this->set_rank($data["rank"]);
		$this->set_blocked($data["blocked"]);
	}

	public function setAll($data)
	{
		if(isset($data["id"])) $this->set_id($data["id"]);

		$this->set_name($data["name"]);

		if(isset($data["password"])) $this->set_password($data["password"]);

		$this->set_email($data["email"]);

		$this->set_rank($data["rank"]);

		if(isset($data["blocked"])) $this->set_blocked($data["blocked"]);
	}

	public function set_id($id)
	{
		$this->id = $id;
	}

	public function set_name($name)
	{
		$this->name = $name;
	}

	public function set_password($password)
	{
		$this->password = md5(sha1(trim($password)));
	}

	public function set_email($email)
	{
		$this->email = $email;
	}

	public function set_rank($rank)
	{
		$this->rank = $rank;
	}

	public function set_blocked($blocked)
	{
		$this->blocked = $blocked;
	}

	public function get_id()
	{
		return $this->id;
	}

	public function get_name()
	{
		return $this->name;
	}

	public function get_password()
	{
		return $this->password;
	}

	public function get_email()
	{
		return $this->email;
	}

	public function get_rank()
	{
		return $this->rank;
	}

	public function get_blocked()
	{
		return $this->blocked;
	}
}

?>